//string 赋值操作
#include <iostream>
#include <string>
using namespace std;

int main()
{
    //创建并赋值字符串
    string s1;
    s1="string比vector简单";
    cout<<"s1:";
    cout<<s1<<endl;

    //复制字符串
    string s2;
    s2=s1;
    cout<<"s2:";
    cout<<s2<<endl;

    //用字符初始化字符串
    string s3;
    s3='x';
    cout<<"s3:"<<endl;
    cout<<s3<<endl;

    //使用assign初始化
    string s4;
    s4.assign("string 操作简便");
    cout<<"s4.size():"<<s4.size()<<endl;
    cout<<"s4:";
    cout<<s4<<endl;

    string s5;
    //在Linux系统里，一个汉字占3个字节
    s5.assign("string 理解容易",12);
    cout<<"s5:";
    cout<<s5<<endl;

    //拷贝字符串
    string s6;
    s6.assign(s5);
    cout<<"s6:";
    cout<<s6<<endl;

    string s7;
    s7.assign(8,'6');
    cout<<"s7:";
    cout<<s7<<endl;

    return 0;
}